﻿<UserControl x:Class="StockTraderRI.Modules.Watch.WatchList.WatchListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Converters="clr-namespace:StockTraderRI.Infrastructure.Converters;assembly=StockTraderRI.Infrastructure"
    Height="Auto" Width="Auto">
    <UserControl.Resources>
        <Converters:TwoDecimalPlaceConverter x:Key="twoDecimalPlaceConverter" />
        <Style x:Key="HeaderContainerStyle" TargetType="{x:Type GridViewColumnHeader}">
            <Setter Property="FontFamily" Value="Franklin Gothic"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="Background" Value="#FF77B6EB"/>
            <Setter Property="Foreground" Value="#FFFFFFFF"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Foreground" Value="Gray"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="PathMouseOverStyle" TargetType="{x:Type Path}">
            <Setter Property="Fill" Value="#FF77B6EB"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Fill" Value="#7F77B6EB"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <StackPanel>
        <ListView Margin="5,5,5,5" x:Name="watchListListView" ItemsSource="{Binding WatchListItems}" 
                  BorderThickness="0" Width="175" Height="160" HorizontalAlignment="Left" IsSynchronizedWithCurrentItem="True" >
            <ListView.ContextMenu>
                <ContextMenu x:Name="watchListContextMenu">
                    <MenuItem Header="Remove" Command="{Binding RemoveWatchCommand}" CommandParameter="{Binding WatchListItems/TickerSymbol}" AutomationProperties.AutomationId="RemoveMenuItem"></MenuItem>
                </ContextMenu>
            </ListView.ContextMenu>
            <ListView.ItemContainerStyle>
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="FontFamily" Value="Franklin Gothic"/>
                    <Setter Property="FontSize" Value="14"/>
                    <Setter Property="FontWeight" Value="Normal"/>
                    <Setter Property="Foreground" Value="#FF77B6EB"/>
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="Green"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Watch List" ColumnHeaderContainerStyle="{StaticResource HeaderContainerStyle}">
                    <GridViewColumn Header="Symbol" DisplayMemberBinding="{Binding Path=TickerSymbol}" Width="65"/>
                    <GridViewColumn Header="Last"  DisplayMemberBinding="{Binding Path=CurrentPrice, Converter={StaticResource twoDecimalPlaceConverter}, ConverterParameter=2}" Width="85" />
                </GridView>
            </ListView.View>
        </ListView>
    </StackPanel>
</UserControl>
